/*
	Purpose: Using the sample of 1940 Census fathers aged 30-50
	         (from 0b), this file creates father income scores
	         at the occupation x south, south-only, race-only, 
	         and race x south levels. 

	Creates: avgincomes_fathers1940_byocc_bysouth.dta
			 avgincomes_fathers1940_bysouth.dta
		     avgincomes_fathers1940_byrace_only.dta
		     avgincomes_fathers1940_byrace_bysouth_only.dta	  
*/

clear
set more off
cd "$Mydirectory1/1_DataSources/CensusData/"

*******************
*** COLLAPSE 
*******************

* 1. Occupation x south
	use ./input/Census1940_fathers_ages30to50_forIncomeScores.dta, clear 

	gen number=1

	collapse (rawsum) number  (mean)  incwage fam_income hh_income , by(occ1950ej south_merge) 
	
	label var incwage "Coarse income score, incwage, by occ. and south"
	label var hh_income "Coarse income score, household income, by occ. and south"
	label var fam_income "Coarse income score, family income, by occ. and south"
	
	rename occ1950ej fatheroccej
	rename number number_1940obs_byocc_bysouth

	save ./output/avgincomes_fathers1940_byocc_bysouth.dta, replace
	
* 2. South-only 
	use ./input/Census1940_fathers_ages30to50_forIncomeScores.dta, clear 

	gen number=1

	collapse (rawsum) number  (mean)  incwage fam_income hh_income , by(south_merge) 
	
	label var incwage "Coarse income score, incwage, by south"
	label var hh_income "Coarse income score, household income, by south"
	label var fam_income "Coarse income score, family income, by south"
	
	rename number number_1940obs_bysouth

	save ./output/avgincomes_fathers1940_bysouth.dta, replace
	
* 3. Race-only 
	use ./input/Census1940_fathers_ages30to50_forIncomeScores.dta, clear 

	gen number=1

	collapse (rawsum) number  (mean)  incwage fam_income hh_income , by(race) 
	
	label var incwage "Coarse income score, incwage, by race"
	label var hh_income "Coarse income score, household income, by race"
	label var fam_income "Coarse income score, family income, by race"
	
	rename number number_1940obs_byrace

	save ./output/avgincomes_fathers1940_byrace_only.dta, replace
	
* 4. Race x south
	use ./input/Census1940_fathers_ages30to50_forIncomeScores.dta, clear 

	gen number=1

	collapse (rawsum) number  (mean)  incwage fam_income hh_income , by(race south_merge) 
	
	label var incwage "Coarse income score, incwage, by race x south"
	label var hh_income "Coarse income score, household income, by race x south"
	label var fam_income "Coarse income score, family income, by race x south"
	
	rename number number_1940obs_byrace_bysouth

	save ./output/avgincomes_fathers1940_byrace_bysouth_only.dta, replace
